<template>
  <section id="contact" class="section contact">
    <div class="container">
      <h2 class="section-title">{{ title }}</h2>
      <div class="contact-content">
        <div class="contact-info">
          <h3>{{ info.heading }}</h3>
          <p>{{ info.description }}</p>
          <div class="contact-methods">
            <div class="contact-method" v-for="(method, index) in info.methods" :key="index">
              <span class="contact-icon">{{ method.icon }}</span>
              <p>{{ method.value }}</p>
            </div>
          </div>
        </div>
        <form class="contact-form" @submit.prevent="handleSubmit">
          <div class="form-group">
            <label for="name">姓名</label>
            <input type="text" id="name" v-model="form.name">
          </div>
          <div class="form-group">
            <label for="email">邮箱</label>
            <input type="email" id="email" v-model="form.email">
          </div>
          <div class="form-group">
            <label for="message">消息</label>
            <textarea id="message" v-model="form.message"></textarea>
          </div>
          <button type="submit" class="btn btn-primary">{{ submitText }}</button>
        </form>
      </div>
    </div>
  </section>
</template>

<script>
export default {
  name: 'ContactSection',
  props: {
    title: {
      type: String,
      default: '联系我们'
    },
    info: {
      type: Object,
      default: () => ({
        heading: '有任何问题？',
        description: '我们非常乐意听取您的反馈和建议，或者回答您关于项目的任何问题。',
        methods: [
          { icon: '✉', value: 'email@example.com' },
          { icon: '☎', value: '+1 234 567 890' }
        ]
      })
    },
    submitText: {
      type: String,
      default: '发送消息'
    }
  },
  data() {
    return {
      form: {
        name: '',
        email: '',
        message: ''
      }
    }
  },
  methods: {
    handleSubmit() {
      this.$emit('submit', { ...this.form });
      this.form = { name: '', email: '', message: '' };
    }
  }
}
</script>

<style scoped>
.section {
  padding: 80px 0;
}

.section-title {
  text-align: center;
  margin-bottom: 50px;
  font-size: 2.5rem;
  color: #333;
}

.contact-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 40px;
}

.contact-methods {
  margin-top: 20px;
}

.contact-method {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.contact-icon {
  display: inline-block;
  width: 20px;
  text-align: center;
  margin-right: 10px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.form-group textarea {
  min-height: 150px;
}

.btn {
  padding: 12px 24px;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
}

.btn-primary {
  background-color: #4CAF50;
  color: white;
}

.btn-primary:hover {
  background-color: #45a049;
}
</style>
